package com.sf.sms.utils;


import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.Date;

/**
 * Created by 80002004 on 2016/7/21.
 */
public class IdEntity implements Comparable {

    /**主键*/
    private Long id;
    /**临时字段- 开始日期*/
    private Date beginDate;
    /**临时字段- 截止日期*/
    private Date endDate;
    /**临时字段- 日期类型*/
    private String dateType;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getDateType() {
        return dateType;
    }

    public void setDateType(String dateType) {
        this.dateType = dateType;
    }

    public int compareTo(Object o) {
        if(null == o)
            return 1;
        if(getClass() != o.getClass())
            return getClass().getName().compareTo(o.getClass().getName());
        IdEntity target = (IdEntity)o;
        if(null == getId())
            return -1;
        if(null == target.getId())
            return 1;
        else
            return getId().compareTo(target.getId());
    }

    public boolean equals(Object object) {
        if(this == object)
            return true;
        if(object == null)
            return false;
        if(getClass() != object.getClass())
            return false;
        IdEntity other = (IdEntity)object;
        if(getId() != null && other.getId() != null)
            return getId().equals(other.getId());
        else
            return false;
    }

    public int hashCode() {
        int prime = 31;
        Long id = getId();
        int result = 1;
        result = 31 * result + (id != null ? id.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
